package com.atguigu.tingshu.user.config;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WxAutoConfiguration {
//    @Value(value = "${wx.login.appId}")
//    private String appId;
//    @Value(value = "${wx.login.appSecret}")
//    private String appSecret;
    @Autowired
    WeChatProperties weChatProperties;

    @Bean
    public WxMaService wxMaService(){
        WxMaServiceImpl wxMaService = new WxMaServiceImpl();
        WxMaDefaultConfigImpl wxMaDefaultConfig = new WxMaDefaultConfigImpl();
        wxMaDefaultConfig.setAppid(weChatProperties.getAppId());
        wxMaDefaultConfig.setSecret(weChatProperties.getAppSecret());
        wxMaService.setWxMaConfig(wxMaDefaultConfig);
        return wxMaService;
    }
}
